package com.frxuexi.lib_http

import com.tencent.mmkv.MMKV
import com.zyj.retrofit.adapter.FlowCallAdapterFactory
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class TokenRetrofitImpl:BaseRetrofitImpl() {

    override fun createRetrofit(): Retrofit {
        val builder = createOkHttpBuild()
        builder.addInterceptor {chain->
            val token = MMKV.defaultMMKV().decodeString("token", "").toString()
            val request = chain.request().newBuilder().addHeader("ferioatoken", token).build()
            chain.proceed(request)
        }

        return Retrofit.Builder()
            .baseUrl(Concast.BASE_URL2)
            .client(builder.build())
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(FlowCallAdapterFactory.create())
            .build()
    }
}